//
//  AboutUsViewController.m
//  MoXiProject
//
//  Created by 周筱雯 on 2017/7/3.
//  Copyright © 2017年 周筱雯. All rights reserved.
//

#import "AboutUsViewController.h"
#import "FeedBackViewController.h"

@interface AboutUsViewController ()
<
    UITableViewDelegate,
    UITableViewDataSource
>

@property (nonatomic,strong) UITableView * tableView;

@end

@implementation AboutUsViewController

-(UITableView *) tableView
{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, DEF_DEVICE_WIDTH, DEF_CONTENT_INTABBAR_HEIGHT) style:UITableViewStylePlain];
        [_tableView setDelegate:self];
        [_tableView setDataSource:self];
        [_tableView setTableHeaderView:[self tableHeaderView]];
        [_tableView setBackgroundColor:DEF_COLOR_F0F0F0];
        
        [MXUtility setExtraCellLineHidde:_tableView tabHeader:YES tabFooter:NO];
    }
    return _tableView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.navigationItem setTitle:@"关于我们"];
    [self.view setBackgroundColor:DEF_COLOR_F0F0F0];
    [self.view addSubview:self.tableView];
    
    [self.view addSubview:[self tableFooterView]];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString * str = @"cell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:str];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:str];
        [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
    }
    if (indexPath.row == 0) {
        
        [cell.textLabel setText:@"意见反馈"];
        [cell.imageView setImage:[UIImage imageNamed:@"yijianfankui"]];
    }
    else if (indexPath.row == 1){
        
        [cell.textLabel setText:@"评分支持"];
        [cell.imageView setImage:[UIImage imageNamed:@"pingfenzhichi"]];
    }
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (indexPath.row == 0) {
        FeedBackViewController * feek = [[FeedBackViewController alloc] init];
        [self.navigationController pushViewController:feek animated:YES];
    }
    else if (indexPath.row == 1){
        
//        NSString *str = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id1259674116"];
//        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
    
    }
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
#pragma mark - b
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
}

-(UIView *) tableHeaderView{

    UIView * header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, DEF_DEVICE_WIDTH, 200)];
    [header setBackgroundColor:[UIColor clearColor]];
    
    UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 50)];
    [view setBackgroundColor:[UIColor clearColor]];
    view.center =  header.center;
    [header addSubview:view];
    
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 0, 50, 45)];
    [imageView setImage:[UIImage imageNamed:@"logo"]];
    [view addSubview:imageView];
    
    UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(imageView.x + imageView.width + 5, 0, view.width - imageView.width - 10, 50)];
    [label setText:[NSString stringWithFormat:@"全球彩票：%@",DEF_APP_VERSION]];
    [view addSubview:label];
    
    return header;

}



-(UIView *) tableFooterView{
    
    CGFloat y = 0;
    if (DEF_DEVICE_HEIGHT == 812) {
        
        y = 88;
        NSLog(@"%f",DEF_DEVICE_HEIGHT);
        
    }else{
        
        y = 64;
        
    }
    
    UIView * header = [[UIView alloc] initWithFrame:CGRectMake(20, DEF_DEVICE_HEIGHT - y - 100, DEF_DEVICE_WIDTH-40, 100)];
    [header setBackgroundColor:DEF_COLOR_F0F0F0];
    
    
    UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, header.width , 100)];
    [label setText:@"Copyright © 深圳市全球科技有限公司. 版权所有."];
    [label setTextAlignment:NSTextAlignmentCenter];
    [label setNumberOfLines:0];
    [label setFont:[UIFont systemFontOfSize:13.f]];
    [label setTextColor:[UIColor lightGrayColor]];
    
    [header addSubview:label];
    
    return header;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
